#ifndef _TTY_DEV_H
#define _TTY_DEV_H

struct tty_ldisc_ops {
    /*
     * The following routines are called from above.
     */
    int  (*open)(struct device *dev, unsigned int flags);
    int  (*close)(struct device *dev);
    int  (*read)(struct device *dev, unsigned char *buf, unsigned int nr);
    int  (*write)(struct tty_dev *tty, const unsigned char *buf, unsigned int nr);
    int  (*ioctl)(struct tty_dev *tty, unsigned int cmd, unsigned int arg);
    void (*set_termios)(struct tty_dev *tty, struct termios *term);

    /*
     * The following routines are called from below.
     */
    void (*receive_buf)(struct tty_dev *tty, const unsigned char *cp, char *fp, unsigned int count);
};

struct tty_ldisc {
	struct tty_ldisc_ops *ops;
}; 

struct tty_dev {
	struct char_dev char_dev;
	unsigned int type;
	struct tty_ldisc *ldisc;
};

struct tty_dev_operations {
	int  (*open)(struct device *dev, unsigned int flags);
    int  (*close)(struct device *dev);
    int  (*write)(struct device *dev, const unsigned char *buf, unsigned int count);
    int  (*ioctl)(struct device *dev, unsigned int cmd, unsigned int arg);
    int  (*put_char)(struct device *dev, unsigned char ch);
    void (*flush_chars)(struct device *dev);
    void (*throttle)(struct device *dev);
    void (*unthrottle)(struct device *dev);
    void (*stop)(struct device *dev);
    void (*start)(struct tty_dev *tty);
    void (*send_xchar)(struct tty_dev *tty, char ch);
    void (*set_termios)(struct tty_dev *tty, struct termios *term);
    int (*break_ctl)(struct tty_dev *tty, unsigned int state);
    void (*wait_until_sent)(struct tty_dev *tty, unsigned int timeout);
};

struct tty_driver {
	struct char_dev_driver char_dev_driver;
	unsigned int type;
	struct tty_dev_operations *tty_dev_ops;
};

#endif /* _TTY_DEV_H */

